package com.itheima;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class MapPractice {
    public static void main(String[] args) {
        Map<String,String> data = new HashMap<>();
        data.put("张一","A");
        data.put("张二","B");
        data.put("张三","C");
        data.put("张四","D");
        data.put("张五","E");
        data.put("张六","F");
        data.put("张七","G");
        data.put("张八","H");
        data.put("张九","I");
        data.put("张十","J");

    }
    public static void count(Map<String,String>data) {
        Map<String,Integer> resultMap = new HashMap<>();
        data.forEach((k,v)->{
            boolean containsKey = resultMap.containsKey(v);
            if (containsKey) {
                Integer oldCount = resultMap.get(v);
                resultMap.put(v, oldCount+1);
            }else {
                resultMap.put(v, 1);
            }
        });

        resultMap.forEach((k,v)->{
            System.out.println(k+" : "+v);
        });

    }
}
